'''
Desc: 太阳花对象
Author: 陈爱国
Date: 2024-08-24 09:37:42
'''
import pygame

class SunFlower(pygame.sprite.Sprite):
    def __init__(self, lasttime):
        # 调用父类构造方法
        super(SunFlower, self).__init__()
        # 定义对象图片
        self.image = pygame.image.load('material/images/SunFlower_00.png').convert_alpha()
        # 图片序列，用于产生动画
        self.images = [pygame.image.load('material/images/SunFlower_{:02d}.png'.format(i)).convert_alpha() for i in range(13)]
        # 图片的矩形区域
        self.rect = self.images[0].get_rect()
        # # 图片top
        # self.rect.top = 150
        # # 图片left
        # self.rect.left = 250
        # 太阳花生成太阳的时间
        self.lasttime = lasttime
        # 血量
        self.energy = 3 * 15
        # 存储碰到的僵尸
        self.zombies = set()

    def update(self, *args):
        self.image = self.images[args[0] % len(self.images)]

        if self.energy <= 0:
            # 太阳花消失
            self.kill()
            # 挡住的僵尸状态改变
            for zombie in self.zombies:
                zombie.isMeetWallNut = False